#!/usr/bin/env bash

# Echo commands
set -o xtrace

# Head node host, which runs glance, api, keystone
HEAD_PUB_IP=${HEAD_PUB_IP:-192.168.168.155}
HEAD_MGT_IP=${HEAD_MGT_IP:-172.16.100.55}

# Networking params
FLOATING_RANGE=${FLOATING_RANGE:-192.168.168.224/27}

# Variables common amongst all hosts in the cluster
COMMON_VARS="$STACKSH_PARAMS MYSQL_HOST=$HEAD_MGT_IP RABBIT_HOST=$HEAD_MGT_IP GLANCE_HOSTPORT=$HEAD_PUB_IP:9292 FLOATING_RANGE=$FLOATING_RANGE"

# Helper to launch containers
function install_domU {
    GUEST_NAME=$1 PUB_IP=$2 MGT_IP=$3 DO_SHUTDOWN=$4 TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $5" ./install_os_domU.sh
}

# Build the HA compute host
install_domU HEADNODE $HEAD_PUB_IP $HEAD_MGT_IP 1 "ENABLED_SERVICES=g-api,g-reg,key,n-cpu,n-net,n-api,n-sch,n-vnc,horizon,mysql,rabbit"
